<template>
  <router-layout>
    <div class="lackyDraw">
      <div class="list">
        <!-- 暂无数据组件 -->
        <Nodata v-if="isNoData"></Nodata>
        <van-list v-else v-model="loading" :finished="finished" @load="onLoad" :offset="0">
          <van-cell v-for="item in dataList" :key="item.id">
            <div class="lacky-list" @click="openLink(item)">
              <van-row type="flex">
                <van-col>
                  <div class="list-img">
                    <img :src="item.file_path" v-if="item.file_path" width="100%" alt>
                  </div>
                </van-col>
                <van-col>
                  <div class="list-right">
                    <div class="right-header">{{item.active_title}}</div>
                    <div class="right-time">{{item.active_desc | text}}</div>
                    <div class="base">
                      <div class="base-text">活动时间：{{item.active_starttime | formate_date}}-{{item.active_endtime | formate_date}}</div>
                    </div>
                    <div v-if="item.top_status!=0">
                      <van-tag type="primary">置顶</van-tag>
                    </div>
                  </div>
                </van-col>
              </van-row>
            </div>
          </van-cell>
        </van-list>
      </div>
    </div>
  </router-layout>
</template>
<script>
import { drawMob_getDrowMobBanners } from "@/api/drawMob";
import moment from "moment";
import Nodata from "../public/nodata/Nodata"; // 导入暂无数据组件
import TitleItem from "../../components/public/title/title";
export default {
  name: "LuckyDraw",
  components: { Nodata, TitleItem },
  data() {
    return {
      isNoData: false,
      loading: false,
      finished: false,
      listQuery: {
        current: 1,
        limit: 5,
        company_id: localStorage.getItem("companyId") || 1
      },
      dataList: [],
      total: 0
    };
  },
  filters: {
    formate_date(v) {
      return moment(v).format("YYYY/MM/DD");
    }
  },
  methods: {
    back() {},
    openLink(e) {
      // alert(JSON.stringify(e.id));
      this.$router.push({ path: "/Trunplate1", query: { drawId: e.id } });
    },
    openLink1() {
      this.$router.replace("/LotteryMe");
    },
    async initList() {
      let res = await drawMob_getDrowMobBanners(this.listQuery);
      if (res.data.status == 100) {
        this.dataList = res.data.data.rows;
        if (!res.data.data.results) {
          this.isNoData = true;
        }
      }
      this.loading = false;
      if (res.data.data.results <= this.dataList.length) {
        this.finished = true;
      }
    },
    onLoad() {
      setTimeout(() => {
        this.listQuery.limit += 2;
        this.initList();
      }, 1000);
    }
  },
  created() {
    this.initList();
  }
};
</script>
<style lang="scss" scoped>
@import "LuckyDraw";
</style>
